﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using IDAL;
using Model;

namespace DAL
{
    public class VSWRCheck : BaseRepository_DT<VSWRCheckInfo>, IVSWRCheck
    {
        #region 静态字段部分
        private const string PARM_VSWRCHECK_PRODUCTSN = "@ProductSN";
        private const string PARM_VSWRCHECK_RECORDTIME = "@RecordTime";
        #endregion

        #region 检索部分
        public IList<VSWRCheckInfo> GetVSWRCheckbyDT(DateTime startTime, DateTime stopTime)
        {
            SqlParameter[] parms = GetDTParameters();
            parms[0].Value = startTime;
            parms[1].Value = stopTime;
            return ExcuteSqlToGetEntities("VSWRCheck_selectbyDT", parms);
        }

        public IList<VSWRCheckInfo> GetVSWRCheckbySN(string productSN)
        {
            SqlParameter parm = new SqlParameter(PARM_VSWRCHECK_PRODUCTSN, SqlDbType.NVarChar, 50);
            parm.Value = productSN;
            return ExcuteSqlToGetEntities("VSWRCheck_selectbySN", parm);
        }
        #endregion

        #region 参数部分
        #endregion

        #region 重新基类部分
        public override VSWRCheckInfo GetEntityRecord(SqlDataReader rdr)
        {
            VSWRCheckInfo pro = new VSWRCheckInfo
            {
                ProductSN = rdr.GetValue(0).ToString(),
                RecordTime = rdr.GetDateTime(1),
                ProductTypeID = rdr.GetValue(2).ToString(),
                UserID = rdr.GetValue(3).ToString(),
                IsPass=rdr.GetBoolean(4)
            };
            return pro;
        }
        #endregion
    }
}
